public class YW_DuckSimulator {

	public static void main(String[] args) {
		YW_DuckSimulator simulator = new YW_DuckSimulator();
		YW_AbstractDuckFactory duckFactory = new YW_CountingDuckFactory();
		simulator.simulate(duckFactory);
	}
 
	void simulate(YW_AbstractDuckFactory duckFactory)  {		
		YW_Quackable yw_RedheadDuck = duckFactory.createRedheadDuck();
		YW_Quackable yw_DuckCall = duckFactory.createDuckCall();
		YW_Quackable yw_RubberDuck =duckFactory.createRubberDuck();
		YW_Quackable yw_GooseDuck = new YW_GooseAdapter(new YW_Goose());
		
		YW_Flock yw_flockOfDucks = new YW_Flock();
		
		yw_flockOfDucks.add(yw_RedheadDuck);
		yw_flockOfDucks.add(yw_DuckCall);
		yw_flockOfDucks.add(yw_RubberDuck);
		yw_flockOfDucks.add(yw_GooseDuck);
		
		YW_Flock yw_flockOfMallads = new YW_Flock();
		
		YW_Quackable yw_MallardDuckOne = duckFactory.createMallardDuck();
		YW_Quackable yw_MallardDuckTwo = duckFactory.createMallardDuck();
		YW_Quackable yw_MallardDuckThree = duckFactory.createMallardDuck();
		YW_Quackable yw_MallardDuckFour = duckFactory.createMallardDuck();	
		
		yw_flockOfMallads.add(yw_MallardDuckOne);
		yw_flockOfMallads.add(yw_MallardDuckTwo);
		yw_flockOfMallads.add(yw_MallardDuckThree);
		yw_flockOfMallads.add(yw_MallardDuckFour);
		

		yw_flockOfDucks.add(yw_flockOfMallads);	
		

		System.out.println("\nMy Duck Simulator: With Observer : DEMO 6");

		YW_Quackologist quackologist = new YW_Quackologist();
		yw_flockOfDucks.registerObserver(quackologist);
		
	
		simulate(yw_flockOfDucks);
			System.out.println("The my ducks quacked " + 
               YW_QuackCounter.getQuacks() + " times: Demo6");
	}

	void simulate(YW_Quackable duck) {
		duck.quack();
	}
}
